/** 
  实习总结
*/
<template>
  <div class="intern-summary-container">
    <!-- 列表页开始indexKey为0 -->
    <div v-if="indexKey === 0">
      <condition-card @reset="reset" @search="onSubmit" label-position="right" label-width="150px">
        <el-row :gutter="24" style="height: 50px;">
          <el-col :span="8">
            <el-form-item :label="$t('internSummary.baseName')">
              <el-input v-model="queryForm.condition.baseName" clearable :maxlength="64" style="width: 100%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('internSummary.collegeAcademy')">
              <el-select v-model="queryForm.condition.collegeAcademy" filterable @change="changeCollege" clearable style="width: 100%">
                <el-option
                  v-for="item in options.collegeAcademy"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('internSummary.major')">
              <el-select v-model="queryForm.condition.major" filterable clearable style="width: 100%">
                <el-option
                  v-for="item in options.major"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24" style="height: 50px;">
          <el-col :span="8">
            <el-form-item :label="$t('internSummary.status')">
              <el-select v-model="queryForm.condition.status" clearable style="width: 100%">
                <el-option
                  v-for="item in options.status"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="$t('internSummary.gradeRange')">
              <el-input v-model="queryForm.condition.scoreStart" clearable :maxlength="64" style="width: calc(50% - 12px);"></el-input>
              {{ $t('graduateBase.to') }}
              <el-input v-model="queryForm.condition.scoreEnd" clearable :maxlength="64" style="width: calc(50% - 10px);"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </condition-card>
      <el-card shadow="never" v-loading="loading" body-style="padding: 24px;" class="card-margin">
        <h1 class="condition-title">{{$t('internSummary.internshipProgramComplete')}}</h1>
        <div class="edu-opertion-bar sub-title">
          <div class="float-left">
            <el-input
              v-model="queryForm.condition.studentIdOrName"
              :placeholder="$t('internSummary.studentIdOrName')"
              style="width:250px"
              @keyup.enter.native="onSubmit">
                <i slot="suffix"
                  class="el-icon-search"
                  style="margin-top:10px;cursor:pointer"
                  @click="onSubmit">
                </i>
            </el-input>
          </div>
          <div class="float-right" style="display: flex;">
            <el-button v-if="permitToExportIntern" type="primary" @click="exportInternAssess()">{{$t('internSummary.exportInternAssessTable')}}</el-button>
            <el-button v-if="permitToExport" type="primary" @click="exportData()">{{$t('common.btn.export')}}</el-button>
            <el-button v-if="permitToAdd" type="primary" @click="addInternSummary()">{{$t('common.btn.add')}}</el-button>
          </div>
        </div>
        <edu-table :pagination="false" :order='false' :tooltipEffect="tooltipEffect" stripe :data="dataList" size="mini" @selection-change="handleSelectionChange">
          <edu-table-column :label="$t('internSummary.studentId')" prop="studentId"></edu-table-column>
          <edu-table-column :label="$t('internSummary.name')" prop="name"></edu-table-column>
          <edu-table-column :label="$t('internSummary.collegeAcademy')" prop="collegeAcademyStr"></edu-table-column>
          <edu-table-column :label="$t('internSummary.major')" prop="majorStr"></edu-table-column>
          <edu-table-column :label="$t('internSummary.baseName')" prop="baseName"></edu-table-column>
          <edu-table-column :label="$t('internSummary.positionName')" prop="positionName"></edu-table-column>
          <edu-table-column :label="$t('internSummary.score')" prop="score"></edu-table-column>
          <edu-table-column :label="$t('internSummary.status')" prop="statusStr">
            <template slot-scope="scope">
              <div class="status-btn-container">
                <el-button v-if="scope.row.status === 0" plain type="info">{{ scope.row.statusStr }}</el-button>
                <el-button v-if="scope.row.status === 1" plain type="danger">{{ scope.row.statusStr }}</el-button>
                <el-button v-if="scope.row.status === 2" plain type="danger">{{ scope.row.statusStr }}</el-button>
                <el-button v-if="scope.row.status === 3" plain type="success">{{ scope.row.statusStr }}</el-button>
                <el-button v-if="scope.row.status === 4" plain type="success">{{ scope.row.statusStr }}</el-button>
              </div>
            </template>
          </edu-table-column>
          <edu-table-column :label="$t('common.text.operation')" fit width="200">
            <template slot-scope="scope">
              <el-button v-if="permitToEdit" type="text" @click="editInternSummary(scope.row)">{{ $t('common.btn.edit') }}</el-button>
              <el-button v-if="permitToDelete" type="text" @click="deleteInternSummary(scope.row)">{{ $t('common.btn.delete') }}</el-button>
              <el-button v-if="permitToDetail" type="text" @click="selectInternSummary(scope.row)">{{ $t('graduateBase.details') }}</el-button>
              <el-button v-if="permitToAudit && (userType === '3.2' && scope.row.status === 1) || (userType === '3.1' && scope.row.status === 2)" type="text" @click="auditInternSummaryInfo(scope.row)">{{ $t('graduateBase.audit') }}</el-button>
            </template>
          </edu-table-column>
        </edu-table>
        <el-row type="flex" class="row-bg" justify="end">
          <el-col>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="queryForm.pageNum_"
              :page-sizes="[20, 40, 80, 100]"
              :page-size="queryForm.pageSize_"
              layout="total, sizes, prev, pager, next, jumper"
              :total="queryForm.total_"
              style="float:right;margin-top:10px"
            ></el-pagination>
          </el-col>
        </el-row>
      </el-card>
    </div>
    <!-- 列表页结束 -->
    <!-- 新增页开始indexKey为1 -->
    <div v-if="indexKey === 1">
      <operate-intern-summary 
      :internSummaryData="internSummaryData"
      :operateMode="operateMode"
      @change-intern-summary-index="changeInternSummaryIndex">
    </operate-intern-summary>
    </div>
    <!-- 新增页结束 -->
    <!-- 校外导师审核页开始 -->
    <div v-if="indexKey === 2">
      <out-audit-intern-summary
      :internSummaryData="internSummaryData"
      :operateMode="operateMode"
      @change-intern-summary-index="changeInternSummaryIndex">
      </out-audit-intern-summary>
    </div>
    <!-- 校外导师审核页结束 -->
    <!-- 导师审核页开始 -->
    <div v-if="indexKey === 3">
      <tutor-audit-intern-summary
      :internSummaryData="internSummaryData"
      :operateMode="operateMode"
      @change-intern-summary-index="changeInternSummaryIndex">
      </tutor-audit-intern-summary>
    </div>
    <!-- 导师审核页结束 -->
    <!-- 详情页开始 -->
    <div v-if="indexKey === 4">
      <intern-summary-detail
      :internSummaryData="internSummaryData"
      :operateMode="operateMode"
      :status="status"
      @change-intern-summary-index="changeInternSummaryIndex"
      @export-intern-assess-table="detailExportInternAssess">
      </intern-summary-detail>
    </div>
    <!-- 详情页结束 -->
    <edu-export-dialog
      :disabled="exportButton"
      :title="$t('message.prompt')"
      ref="downloadRef"
      :data="exportResult">
    </edu-export-dialog>
  </div>
</template>
<script>
import graduateStudentApi from 'common/src/api/graduateStudent/graduateStudent'
import { queryDic } from "common/src/api/dictionary"
import UTILS from "common/src/utils/utils"
import operateInternSummary from './operateInternSummary'
import outAuditInternSummary from './outAuditInternSummary'
import tutorAuditInternSummary from './tutorAuditInternSummary'
import internSummaryDetail from './internSummaryDetail'
export default {
  components: {
    'operate-intern-summary': operateInternSummary,
    'out-audit-intern-summary': outAuditInternSummary,
    'tutor-audit-intern-summary': tutorAuditInternSummary,
    'intern-summary-detail': internSummaryDetail
  },
  data () {
    return {
      auths: [],
      userType: '',
      // 使用这个切换当前页面显示哪个模式
      indexKey: 0,
      userInfo: {},
      permitToExportIntern: false,
      permitToExport: false,
      permitToAdd: false,
      permitToEdit: false,
      permitToDelete: false,
      permitToDetail: false,
      permitToAudit: false,
      innerVisible: false,
      tableFlag: false,
      multipleSelection: [],
      queryForm: {
        pageNum_: 1,
        pageSize_: 20,
        total_: 0,
        condition: {
          baseName: '',
          collegeAcademy: '',
          major: '',
          status: '',
          scoreStart: '',
          scoreEnd: '',
          studentIdOrName: ''
        }
      },
      dataListProp: {},
      dialogMode: 'add',
      options: {
        // 学院
        collegeAcademy: [],
        // 专业
        major: [],
        // 当前状态
        status: [
          {
            label: this.$t('internSummary.draft'),
            value: 0
          },
          {
            label: this.$t('internSummary.outSchoolTutorReview'),
            value: 1
          },
          {
            label: this.$t('internSummary.mentorReview'),
            value: 2
          },
          {
            label: this.$t('internSummary.audited'),
            value: 3
          },
          {
            label: this.$t('internSummary.dismissed'),
            value: 4
          }
        ],
        // 培养层次
        trainingLevelList: [],
        // 培养类别
        trainingTypeList: [],
        // 学位类型
        degreeTypeList: [],
        // 学习形式
        learnFormList: [],
        // 组件中的专业
        majorList: []
      },
      dataList: [],
      exportButton: false,
      exportResult: null,
      internSummaryData: {},
      operateMode: 'add',
      status: ''
    }
  },
  created() {
    // 获取当前用户auths权限
    let sessiondata = JSON.parse(localStorage.getItem("sessiondata"));
    if (sessiondata) {
      if (sessiondata.auths) {
        this.auths = sessiondata.auths;
      }
      if (sessiondata.mockUser || sessiondata.user) {
        this.userInfo = sessiondata.mockUser || sessiondata.user;
      }
    }
    graduateStudentApi.queryinternSummaryList(this.queryForm).then(res => {
      this.dataList = res.data.list;
      this.queryForm.total_ = res.data.total_;
    });
    graduateStudentApi.getPracticeRoleBySession().then(res => {
      if (res.data) {
        this.userType = res.data;
      }
    });
    // 获取字典
    this.initOptions();
  },
  methods: {
    // 校验特殊字符$
    checkSpecial(rule, value, callback) {
      let regEn = /[`$]/im;
      if (regEn.test(value)) {
        callback(new Error(this.$t('graduateBase.specialText')))
      } else {
        callback();
      }
    },
    async initOptions() {
      // 筛选条件字典查询
      let data = {
        lang: this.$store.getters.language || "cn",
        type: "allChild",
        keys: [
          "X_PYCC", // 培养层次
          "X_PYLB", // 培养类别
          "X_XWLX", // 学位类型
          "X_XXXS", // 学习形式
          "X_YX" // 学院
        ]
      };
      await queryDic(data).then(res => {
        this.options["trainingLevelList"].push({value: '', label: "全部" });
        this.options["trainingTypeList"].push({value: '', label: "全部" });
        this.options["degreeTypeList"].push({value: '', label: "全部" });
        this.options["learnFormList"].push({code: '', name: "全部" });
        this.options["majorList"].push({code: '', name: "全部" });
        UTILS.fillSelect(
          {
            trainingLevelList: "X_PYCC", // 培养层次
            trainingTypeList: "X_PYLB", // 培养类别
            degreeTypeList: "X_XWLX", // 学位类型
            learnFormList: "X_XXXS", // 学习形式
            collegeAcademy: "X_YX" // 学院
          },
          res.data,
          this.options
        );
      });
      // 获取所有专业
      graduateStudentApi.getMajorByCollage([]).then(res => {
        if (res.code === 200) {
          if (Array.isArray(res.data) && res.data.length > 0) {
            res.data.map(item => {
              this.options.majorList.push({
                label: (this.$store.getters.language === 'cn' || !this.$store.getters.language) ? item.name : item.nameEn,
                value: item.code
              });
            });
          }
        }
      });
    },
    // 修改学院
    changeCollege(val) {
      this.options.major = [];
      this.queryForm.condition.major = '';
      let parmas = [];
      if (val) {
        parmas = [val];
        graduateStudentApi.getMajorByCollage(parmas).then(res => {
          if (res.code === 200) {
            if (Array.isArray(res.data) && res.data.length > 0) {
              this.options.major = val ? res.data : [...[{code: '0', name: '全部'}], ...res.data];
            }
          }
        });
      } else {
        this.options.major = [];
      }
    },
    onSubmit() {
      this.queryForm.pageNum_ = 1;
      this.getListData();
    },
    // 新增实习总结
    addInternSummary() {
      graduateStudentApi.queryInternSummaryBasicInfo({
        "studentId": this.userInfo.uid,
        "id": "",
        "status": 0
      }).then(res => {
        if (res.code === 200) {
          let currentInto = JSON.parse(JSON.stringify(res.data));
          currentInto.collegeAcademyStr = UTILS.translateLabel(this.options.collegeAcademy, currentInto.collegeAcademy, 'value', 'label')
          currentInto.majorStr = UTILS.translateLabel(this.options.majorList, currentInto.major, 'value', 'label')
          currentInto.trainingLevelStr = UTILS.translateLabel(this.options.trainingLevelList, currentInto.trainingLevel, 'value', 'label')
          currentInto.trainingCategoryStr = UTILS.translateLabel(this.options.trainingTypeList, currentInto.trainingCategory, 'value', 'label')
          currentInto.degreeTypeStr = UTILS.translateLabel(this.options.degreeTypeList, currentInto.degreeType, 'value', 'label')
          currentInto.formLearningStr = UTILS.translateLabel(this.options.learnFormList, currentInto.formLearning, 'value', 'label')
          this.internSummaryData = currentInto;
          this.indexKey = 1;
          this.operateMode = 'add';
        }
      });
    },
    // 返回列表页
    changeInternSummaryIndex() {
      this.indexKey = 0;
      this.reset();
    },
    // 编辑实习总结
    editInternSummary(row) {
      if (row.status !== 0) {
        this.$eduAlert(this.$t('internSummary.permitEditCondition'), this.$t('graduateBase.prompt'), {
          type: 'warning'
        })
        return
      }
      graduateStudentApi.queryInternSummaryBasicInfo({
        "studentId": row.studentId,
        "id": row.id,
        "status": row.status
      }).then(res => {
        if (res.code === 200) {
          let currentInto = JSON.parse(JSON.stringify(res.data));
          currentInto.collegeAcademyStr = UTILS.translateLabel(this.options.collegeAcademy, currentInto.collegeAcademy, 'value', 'label')
          currentInto.majorStr = UTILS.translateLabel(this.options.majorList, currentInto.major, 'value', 'label')
          currentInto.trainingLevelStr = UTILS.translateLabel(this.options.trainingLevelList, currentInto.trainingLevel, 'value', 'label')
          currentInto.trainingCategoryStr = UTILS.translateLabel(this.options.trainingTypeList, currentInto.trainingCategory, 'value', 'label')
          currentInto.degreeTypeStr = UTILS.translateLabel(this.options.degreeTypeList, currentInto.degreeType, 'value', 'label')
          currentInto.formLearningStr = UTILS.translateLabel(this.options.learnFormList, currentInto.formLearning, 'value', 'label')
          this.internSummaryData = currentInto;
          this.indexKey = 1;
          this.operateMode = 'edit';
        }
      });
    },
    // 删除实习总结
    deleteInternSummary(row) {
      if (row.status !== 0) {
        this.$eduAlert(this.$t('internSummary.permitDeleteCondition'), this.$t('graduateBase.prompt'), {
          type: 'warning'
        })
        return
      }
      this.$delConfirm().then(_ => {
        graduateStudentApi.operateInternSummary({
          "id": row.id,
          "deleteFlag": "1",
          "status": row.status
        }).then(res => {
          if (res.code === 200) {
            this.$message.success(this.$t('common.tips.deleteSuccess'));
            this.onSubmit();
          }
        })
      })
    },
    // 查看实习总结详情
    selectInternSummary(row) {
      graduateStudentApi.queryInternSummaryBasicInfo({
        "studentId": row.studentId,
        "id": row.id,
        "status": row.status
      }).then(res => {
        if (res.code === 200) {
          let currentInto = JSON.parse(JSON.stringify(res.data));
          currentInto.collegeAcademyStr = UTILS.translateLabel(this.options.collegeAcademy, currentInto.collegeAcademy, 'value', 'label')
          currentInto.majorStr = UTILS.translateLabel(this.options.majorList, currentInto.major, 'value', 'label')
          currentInto.trainingLevelStr = UTILS.translateLabel(this.options.trainingLevelList, currentInto.trainingLevel, 'value', 'label')
          currentInto.trainingCategoryStr = UTILS.translateLabel(this.options.trainingTypeList, currentInto.trainingCategory, 'value', 'label')
          currentInto.degreeTypeStr = UTILS.translateLabel(this.options.degreeTypeList, currentInto.degreeType, 'value', 'label')
          currentInto.formLearningStr = UTILS.translateLabel(this.options.learnFormList, currentInto.formLearning, 'value', 'label')
          this.internSummaryData = currentInto
          this.internSummaryData['auditStatus'] = row.status
          this.operateMode = 'details'
          this.indexKey = 4
        }
      });
    },
    // 审核实习总结
    auditInternSummaryInfo(row) {
      graduateStudentApi.queryInternSummaryBasicInfo({
        "studentId": row.studentId,
        "id": row.id,
        "status": row.status
      }).then(res => {
        if (res.code === 200) {
          let currentInto = JSON.parse(JSON.stringify(res.data));
          currentInto.collegeAcademyStr = UTILS.translateLabel(this.options.collegeAcademy, currentInto.collegeAcademy, 'value', 'label')
          currentInto.majorStr = UTILS.translateLabel(this.options.majorList, currentInto.major, 'value', 'label')
          currentInto.trainingLevelStr = UTILS.translateLabel(this.options.trainingLevelList, currentInto.trainingLevel, 'value', 'label')
          currentInto.trainingCategoryStr = UTILS.translateLabel(this.options.trainingTypeList, currentInto.trainingCategory, 'value', 'label')
          currentInto.degreeTypeStr = UTILS.translateLabel(this.options.degreeTypeList, currentInto.degreeType, 'value', 'label')
          currentInto.formLearningStr = UTILS.translateLabel(this.options.learnFormList, currentInto.formLearning, 'value', 'label')
          this.internSummaryData = currentInto
          // 校外导师userType为3.2，indexKey为2
          // 校内导师userType为3.1，indexKey为3
          if (this.userType === '3.2') {
            this.indexKey = 2
          } else if (this.userType === '3.1') {
            this.indexKey = 3
          }
          // this.indexKey = 3
          this.operateMode = 'audit';
        }
      });
    },
    // 轮询直到获取key值的接口返回
    cycleToGetKey() {
      let currentIds = [];
      if (this.multipleSelection.length > 0) {
        this.multipleSelection.forEach((element) => {
          currentIds.push(element.id);
        });
      }
      graduateStudentApi.exportInternSummaryInfo({
        "baseName": this.queryForm.condition.baseName,
        "collegeAcademy": this.queryForm.condition.collegeAcademy,
        "major": this.queryForm.condition.major,
        "status": this.queryForm.condition.status,
        "scoreStart": this.queryForm.condition.scoreStart,
        "scoreEnd": this.queryForm.condition.scoreEnd,
        "studentIdOrName": this.queryForm.condition.studentIdOrName,
        "selectRowIds": currentIds
      }).then(res => {
        if (res.success) {
          this.$refs.downloadRef.close();
          this.exportButton = false;
          this.normalDelayRequest(res.key, res.msg);
        } else {
          this.cycleToGetKey();
        }
      });
    },
    // 导出异步
    delayRequest(key, name) {
      setTimeout(() => {
        graduateStudentApi.downloadGetKey(key, name).then(res => {
          this.exportResult = res.data;
          if (res.code == 200 && res.data.status) {
            this.exportButton = false;
            let path =
              '/api/practiceservice/export/file?path=' +
              res.data.path + '&name=' + name;
            // window.open(path);
            window.location.href = path;
            this.$message.success(this.$t('result.exportSuccessfully'));
            this.$refs.downloadRef.close();
          } else {
            this.delayRequest(key, name);
          }
        });
      }, 3000);
    },
    // Normal导出异步
    normalDelayRequest(key, name) {
      setTimeout(() => {
        graduateStudentApi.downloadGetKey(key).then(res => {
          this.exportResult = res.data;
          if (res.code == 200 && res.data.status) {
            this.exportButton = false;
            let path =
              '/api/practiceservice/export/file?path=' +
              res.data.path + '&name=' + name;
            // window.open(path);
            window.location.href = path;
            this.$message.success(this.$t('result.exportSuccessfully'));
            this.$refs.downloadRef.close();
          } else {
            this.delayRequest(key, name);
          }
        });
      }, 3000);
    },
    formDownload(options) {
      let config = options
      let iframe = document.createElement('iframe')
      iframe.style.display = "none";
      iframe.setAttribute('id', 'down-file-iframe')
      let form = document.createElement('form')
      form.style.display = "none";
      form.setAttribute('id', 'downloadForm')
      form.setAttribute('target', 'down-file-iframe')
      form.setAttribute('method', config.method)
      form.setAttribute('action', window.location.origin + config.url)
      iframe.append(form)
      document.body.append(iframe)
      document.getElementById('downloadForm').submit()
      iframe.remove()
    },
    urlEncode (str) {
      let temp = str;
      temp = (temp + '').toString();
      return encodeURIComponent(temp).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
    },
    // 导出实习考核表
    async exportInternAssess() {
      let currentIds = [];
      if (this.multipleSelection.length > 0) {
        this.multipleSelection.forEach((element) => {
          currentIds.push(element.id);
        });
      }
      // 判断导出项是否全部审核完成
      graduateStudentApi.validateInternAssess({
        "baseName": this.queryForm.condition.baseName,
        "collegeAcademy": this.queryForm.condition.collegeAcademy,
        "major": this.queryForm.condition.major,
        "status": this.queryForm.condition.status,
        "scoreStart": this.queryForm.condition.scoreStart,
        "scoreEnd": this.queryForm.condition.scoreEnd,
        "studentIdOrName": this.queryForm.condition.studentIdOrName,
        "selectRowIds": currentIds
      }).then(_ => {
        this.exportResult = null;
        this.$refs.downloadRef.open();
        this.exportButton = true;
        setTimeout(() => {
          let domIframe = document.createElement("iframe");
          domIframe.src = "/api/practiceservice/practiceSummary/exportBatchWordZip?baseName="
          + this.urlEncode(this.queryForm.condition.baseName)
          + "&collegeAcademy=" + this.urlEncode(this.queryForm.condition.collegeAcademy)
          + "&major=" + this.urlEncode(this.queryForm.condition.major)
          + "&status=" + this.urlEncode(this.queryForm.condition.status)
          + "&scoreStart=" + this.urlEncode(this.queryForm.condition.scoreStart)
          + "&scoreEnd=" + this.urlEncode(this.queryForm.condition.scoreEnd)
          + "&studentIdOrName=" + this.urlEncode(this.queryForm.condition.studentIdOrName)
          + "&selectRowIdStr=" + this.urlEncode(currentIds.join(','))
          domIframe.style.display = "none";
          document.body.appendChild(domIframe);
          this.exportResult = '';
          this.exportButton = false;
          this.$message.success(this.$t('result.exportSuccessfully'));
          this.$refs.downloadRef.close();
        }, 2000);
      })
      // setTimeout(() => {
      //   this.formDownload({
      //     url: "/api/practiceservice/practiceSummary/exportBatchWordZip?selectRowIdStr=" + currentIds.join(','),
      //     method: "post"
      //   });
      //   this.exportResult = '';
      //   this.exportButton = false;
      //   this.$message.success(this.$t('result.exportSuccessfully'));
      //   this.$refs.downloadRef.close();
      // }, 2000);
    },
    // 详情导出实习考核表
    detailExportInternAssess(id) {
      this.exportResult = null;
      this.$refs.downloadRef.open();
      this.exportButton = true;
      setTimeout(() => {
        let domIframe = document.createElement("iframe");
        domIframe.src = "/api/practiceservice/practiceSummary/exportBatchWordZip?selectRowIdStr=" + id;
        domIframe.style.display = "none";
        document.body.appendChild(domIframe);
        this.exportResult = '';
        this.exportButton = false;
        this.$message.success(this.$t('result.exportSuccessfully'));
        this.$refs.downloadRef.close();
      }, 2000);
    },
    // 导出
    exportData() {
      // 1、第一步：调该接口，获取key值以及msg中的文件名
      // 2、第二步：将key值放入接口传参
      // 3、第三步：传入path值以及name(msg中的文件名)值，下载文件
      this.exportResult = null;
      this.$refs.downloadRef.open();
      this.exportButton = true;
      this.cycleToGetKey();
    },
    getListData() {
      this.queryForm.condition.baseName = this.queryForm.condition.baseName.trim()
      this.queryForm.condition.scoreStart = this.queryForm.condition.scoreStart.trim()
      this.queryForm.condition.scoreEnd = this.queryForm.condition.scoreEnd.trim()
      this.queryForm.condition.studentIdOrName = this.queryForm.condition.studentIdOrName.trim()
      let expReg = /^(\d{0,3})(\.\d{1,2})?$/ 
      if (!expReg.test(this.queryForm.condition.scoreStart) || Number(this.queryForm.condition.scoreStart) > 100) {
        this.$eduAlert(this.$t('baseAssess.validateScore'), this.$t('graduateBase.prompt'), {
          type: 'warning'
        })
        return
      }
      if (!expReg.test(this.queryForm.condition.scoreEnd) || Number(this.queryForm.condition.scoreEnd) > 100) {
        this.$eduAlert(this.$t('baseAssess.validateScore'), this.$t('graduateBase.prompt'), {
          type: 'warning'
        })
        return
      }   
      graduateStudentApi.queryinternSummaryList(this.queryForm).then((res) => {
        this.dataList = res.data.list;
        this.queryForm.total_ = res.data.total_;
      })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.queryForm.pageSize_ = val;
      this.getListData();
    },
    handleCurrentChange(val) {
      this.queryForm.pageNum_ = val;
      this.getListData();
    },
    reset() {
      Object.keys(this.queryForm.condition).forEach(key => this.queryForm.condition[key] = '');
      this.multipleSelection = [];
      this.changeCollege();
      this.onSubmit();
    }
  },
  watch: {
    auths: {
      handler(newVal) {
        if (newVal && Array.isArray(newVal) && newVal.length > 0) {
          newVal.some(item => {
            if (item.authCode === 'graduateStu-internSummary-exportInternForm') {
              this.permitToExportIntern = true;
            }
            if (item.authCode === 'graduateStu-internSummary-export') {
              this.permitToExport = true;
            }
            if (item.authCode === 'graduateStu-internSummary-add') {
              this.permitToAdd = true;
            }
            if (item.authCode === 'graduateStu-internSummary-edit') {
              this.permitToEdit = true;
            }
            if (item.authCode === 'graduateStu-internSummary-delete') {
              this.permitToDelete = true;
            }
            if (item.authCode === 'graduateStu-internSummary-details') {
              this.permitToDetail = true;
            }
            if (item.authCode === 'graduateStu-internSummary-audit') {
              this.permitToAudit = true;
            }
          });
        }
      },
      deep: true,
      immediate: true
    }
  }
}
</script>
<style lang="scss" scoped>
  .condition-title {
    color: #2b3b4e;
    font-size: 18px;
    line-height: 24px;
    font-weight: bold;
  }
  .edu-page-title {
    span {
      line-height: 24px;
      display: inline-block;
      padding-right: 10px;
      font-size: 18px;
      font-weight: bold;
      color: #2b3b4e;
    }
  }
  .sub-title {
    margin: 16px 0;
    font-size: 16px;
    color: #000020;
    letter-spacing: 0;
  }
  .template-setting-dialog ::v-deep {
    .el-select {
      width: 100%!important;
    }
  }
  .status-btn-container ::v-deep {
    .el-button {
      width: 100px;
      cursor: auto;
    }
    .el-button--danger {
      padding: 9px 15px;
      min-width: 0;
    }
  }
  .intern-summary-container ::v-deep {
    .el-dialog__body {
      word-break: break-all!important;
    }
  }
</style>
